<?php
class desktop extends control {
	
	private $settings;
	private $app;
	

	public function index(){
		//echo 'hello world';
		//$this->loadView('public/header');
		if($this->user_id) {
			$this->settings = $this->loadModel('settings');
			$cond = array('user_id'=>$this->user_id,'setting_type'=>'desktop');
			$field = array('user_id','desktop_image');
			$data = $this->settings->find($cond,$field);
			//print_r($rows);
			$this->loadView('desktop/desktop',$data);
		//	echo $user_id;exit;
		} else {
			$this->loadView('login/login');
			//$this->loadView('login/login');
		}
		
		//$this->loadView('public/footer');
	}


	/**
	  *开始菜单的初始化数据
	  *
	**/
	public function getStartConfig() {
		$this->app = $this->loadModel('app_lib');
		$rows = $this->app->getConfigApp($this->user_id);
		$data = array('user_name'=>$this->user_name,'rows'=>$rows);
		echo json_encode($data);
	}
	
	public function updateDesktopBackground() {
		$desktopImage = $this->load->uri->getSeg(2);
		$this->settings = $this->loadModel('settings');
		$result = $this->settings->updateDesktopBackground($desktopImage,$this->user_id);
		//echo $desktopImage;
		if($result) echo config::DESKTOP_IMAGE_PATH.$desktopImage;
	
	}	
}
?>
